#ifndef BIT_WIN_GENERIC_BITWISE
#define BIT_WIN_GENERIC_BITWISE


#include <QSharedData>


class QString;


namespace BitWin
{


class BitRange;


//---- Generic abstract class for bitwise-representable data

// Class and explicitly shared pointer to class instance.
// NB! Client should use explicitly shared pointer only!
class GenericBitwise;
typedef QExplicitlySharedDataPointer<GenericBitwise> PGenericBitwise;


class GenericBitwise: public QSharedData
{
    // Declared, but not implemented
    GenericBitwise& operator=(const GenericBitwise&);
    GenericBitwise(const GenericBitwise&);

protected:

    GenericBitwise();

public:

    virtual ~GenericBitwise();

    // Key virtual methods

    // Get bitwise data as a string literal
    virtual QString bitwise() const =0;

    // Get data as a hex string
    virtual QString hex() const =0;

    // Get data as a decimal string
    virtual QString dec() const =0;

    // Get bitwise data as a string literal. Bits in the given range
    // are visible only; other bits are replaced by spaces.
    QString bitwise(const BitRange&) const;

    // Factory methods and maker classes, wrapping such methods
    // into the operator();
    // create appropriate child class to represent bitwise
    // data of the given kind.
    // Templates are implemented in "generic_bitwise_templates.h"

    template <typename T>
    static PGenericBitwise fromIntegral(const T value);

    template <typename T>
    class FromIntegral;

    template <typename T>
    static PGenericBitwise fromSequence(const T& value);

    template <typename T>
    class FromSequence;

    // Create an empty (i.e. having no data) GenericBitwise
    // child class instance.
    static PGenericBitwise empty();
};


}; // BitWin namespace end


#endif
